#include<bits/stdc++.h>

using namespace std;
struct Date {
    int year;
    int month;
    int day;
};

void input(Date &d) {
    cin >> d.year >> d.month >> d.day;
}

bool leap(Date &d) {
    return d.year % 4 == 0 && d.year % 100 || d.year % 400 == 0;
}

int DAYS[][13] = {{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
                  {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},};

int get_days(Date &d) {
    int tot = d.day;
    for (int i = 0; i < d.month; i++) {
        tot += DAYS[leap(d)][i];
    }
    return tot;
}

int main() {
    Date d;
    input(d);
    cout << get_days(d);

    return 0;
}